import React, {useEffect, useState} from 'react';
import RNLocalize from "react-native-localize";
import AsyncStorage from '@react-native-async-storage/async-storage';

const l10n: { [key: string]: { [key: string]: string } } = {
    'en': {
        'Guest.slogan': 'Welcome to the SmartX community',
        'Guest.register': 'Register Wallet',
        'Guest.import': 'Import Wallet',

        "Register.memo": "Wallet name",
        "Register.passwordPlaceholder": "Wallet password",
        "Register.repassword": "Confirm password",
        "Register.passwordError": "Please input a password",
        "Register.repasswordError": "Fails to confirm password",
        "Register.read": "I've read and agreed",
        "Register.privacy": "service & privacy notice",

        "Import.password": "Password",
        "Import.passwordError": "Password wrong",
        "Import.privateKey": "PrivateKey",
        'Import.keyStore':"KeyStore",
        "Import.correctPrivatekey":"PrivateKey wrong",
        "Import.invalid": "invalid",

        "Tabs.assets": "Assets",
        "Tabs.apps": "DApps",
        "Tabs.pool": "Pool",
        "Tabs.my": "My",
        "Tabs.chat":"Mail",
        "Tabs.group":"Group",
        "Tabs.HotAssets": "Hot Assets",

        "Assets.wallet": "Wallet",
        "Assets.balance": "Total (SAT)",
        "Assets.send": "Send",
        "Assets.preSend":"Transfer List",
        "Assets.receive": "Receive",
        "Assets.txs": "Txs",
        "Assets.assets": "Assets",
        "Assets.scanQrcode": "Scan Qrcode",
        "Assets.receive.switch": "Switch",
        "Assets.txs.all": "All",
        "Assets.txs.pending": "Pending",
        "Assets.txs.id": "TX ID",
        "Assets.txs.out": "OUT",
        "Assets.txs.in": "IN",
        "Assets.txs.success": "Success",
        "Assets.txs.failure": "Failure",
        "Assets.txs.waiting": "Waiting",
        "Assets.txs.lose": "lose",
        "Assets.txs.resend": "Resend",
        "Assets.tx.title": "Transaction Details",
        "Assets.tx.sender": "Sender",
        "Assets.tx.receiver": "Receiver",
        "Assets.tx.gas": "Gas",
        "Assets.tx.timestamp": "Timestamp",
        "Assets.tx.blockNumber": "Block Number",
        "Assets.tx.hash": "Transaction Hash",
        "Assets.tx.remarks": "Transaction Remarks",
        "Assets.tx.Blockbrowser": "Block browser",
        "Assets.tx.data": "Transaction Message",
        "Assets.tx.contractCall":"Contract call",
        "Assets.tx.contractRelease":"Contract create",


        "Assets.send.receiver": "Receiver Address",
        "Assets.send.sendToAccount": "Enter Address",
        "Assets.send.scan": "Scan Address",
        "Assets.send.recent": "Recent Transactions",
        "Assets.send.amount": "Amount",
        "Assets.send.remarks": "Remarks",
        "Assets.send.balance": "Balance",
        "Assets.send.pledge": "Pledge",
        "Assets.send.all": "All",
        "Assets.send.selectAsset": "Select Asset",
        "Assets.send.receiverInvalid": "Invalid address",
        "Assets.send.cannotToSelf": "Cannot send to self",
        "Assets.send.mustSelectCoin": "Select asset first",
        "Assets.send.amountInvalid": "Invalid number",
        "Assets.send.balanceNotEnough": "Balance is not enough",
        "Assets.send.sendFail": "Fails to send transaction, retry again",
        "Assets.send.sendSuccess": "The transaction has been broadcast",
        "Assets.send.OK": "OK",
        "Assets.confirmDelete":"Confirm to delete ",

        "Assets.send.payDetailTitle": "Pay Detail",//TODO 2021-03-07
        "Assets.send.payDetailReceiver": "Receiver Address",//TODO 2021-03-07
        "Assets.send.payDetailTitleSender": "Send Address",//TODO 2021-03-07
        "Assets.send.payDetailBtnOK": "OK",//TODO 2021-03-07
        "Assets.send.pwHint": "Wallet Password",//TODO 2021-03-07
        "Assets.send.pwReset": "Forget Passwrod？",//TODO 2021-03-07
        "Assets.send.Notice":"Note: the transfer fee is 0.002sat, please pay attention to the balance!",

        "Txs.AlertDel":"Confirm to delete this information.",

        "Token.tokenSearch":"Token Search",
        "Token.tokenNonExit":"The token does not exist",
        "Token.hotTokens":"Hot tokens",

        "Pool.title": 'SmartX Contract', //TODO 2021-03-08
        "Pool.zyhy.create": 'Create Pledge Contract',//TODO 2021-03-08
        "pool.zyhy.releaseHY":'Contract Release',
        "pool.zyhy.moveHY":'Contract Move',
        "pool.zyhy.getHY":'Get Contract',
        "pool.zyhy.recallHY":'Recall Contract',
        "pool.zyhy.decideRecallHY":'Are you sure to cancel the retrieval contract？',
        "pool.zyhy.addHY":'Add Contract',
        "Pool.zyhy.qryHint": 'Contract Search',//TODO 2021-03-08
        "Pool.zyhy_my": 'My Pledge',//TODO 2021-03-08
        "Pool.zyhy_all": 'Pledge Contract',//TODO 2021-03-08C
        "Pool.zyhy_zjc": 'SAT Pool',//TODO 2021-03-08
        "Pool.zyhy_nhl": 'Rate',//TODO 2021-03-08
        "Pool.zyhy_zt": 'Status',//TODO 2021-03-08
        "Pool.zyhy_zed": 'Total Voucher',//TODO 2021-03-08
        "Pool.zyhy_myzb": 'My Ratio',//TODO 2021-03-08
        "Pool.zyhy_mypz": 'My Voucher',//TODO 2021-03-08
        "Pool.zyhy_mysy": 'My Balance',//TODO 2021-03-08
        "Pool.zyhy_rec": 'Current zhy Strip',//TODO 2021-03-08
        "Pool.zyhy.createHint": 'Available Bonus Pool',//TODO 2021-03-08
        "Pool.zyhy.create_moneyHint": 'Enter Contract Amount',//TODO 2021-03-08
        "Pool.btn_create": 'Establish',//TODO 2021-03-08
        "Pool.op.btn_create": 'Add',//TODO 2021-03-08
        "Pool.op.btn_modife": 'Transfer',//TODO 2021-03-08
        "Pool.op.btn_delete": 'Release',//TODO 2021-03-08
        "Pool.op.qhpz": 'Release Voucher',//TODO 2021-03-08
        'Pool.op.zypz': 'transfer Voucher', //TODO 2021-03-23
        "Pool.op.pzcountHint": 'Please Enter The Number of Vouchers',//TODO 2021-03-08
        "Pool.op.zb25": '25%',//TODO 2021-03-08
        "Pool.op.zb50": '50%',//TODO 2021-03-08
        "Pool.op.zb75": '75%',//TODO 2021-03-08
        "Pool.op.zbMax": 'MAX',//TODO 2021-03-08
        "Pool.op.kypz": 'Usable Voucher: ',//TODO 2021-03-08
        "Pool.op.zb": 'Proportion：',//TODO 2021-03-08
        "Pool.op.zyzc": 'Transfer of Assets',//TODO 2021-03-08
        "Pool.op.zcmoneyHint": 'Please Input Asset Amount',//TODO 2021-03-08
        "Pool.op.zyz": 'Transfer To',//TODO 2021-03-08
        "Pool.op.hyaddrHint": 'Please Enter The Contract Address',//TODO 2021-03-08
        "Pool.op.qhzc": 'Recovery of Assets',//TODO 2021-03-08
        "Pool.op.qhzt": 'Retrieve Status',//TODO 2021-03-08
        "Pool.op.btnqh": 'Retrieval',//TODO 2021-03-08
        "Pool.op.xh": 'Serial number',//TODO 2021-03-08
        "Pool.op.je": 'Amount of Money',//TODO 2021-03-08
        "Pool.op.zt": 'State',//TODO 2021-03-08
        "Pool.op.recall": 'Recall',

        "Pool.op.hyH": 'Hour',//TODO 2021-03-08
        "Pool.op.hyM": 'Minute',//TODO 2021-03-08
        "Pool.op.hyS": 'Second',//TODO 2021-03-08
        "Pool.op.hyHint": 'It Can Be Confirmed After The Test',//TODO 2021-03-08
        "Pool.op.qrmoney": 'Confirmed Amount',//TODO 2021-03-08
        "Pool.op.qrmoneyHint": 'Please Enter The Amount',//TODO 2021-03-08
        "Pool.op.blc": 'Balance：',//TODO 2021-03-08
        'Pool.op.excuting': 'Please Watting Excuting Finish',//TODO 2021-03-26
        "pool.op.pooling":"Contract in progress",
        "pool.op.addMoneyError":"The added amount must be greater than 1000 SAT",
        "pool.op.releaseMoneyError":"Release amount error",
        "pool.op.moveMoneyError":"Move amount error",
        "pool.op.moveAddressError":"Move address error",
        "pool.op.minCreateContract":"Contract creation requirement: at least 1000000sat",
        "pool.op.contractNonExit":"The contract does not exist",
        "pool.op.tryLater":'Please try again later!',
        "pool.op.getLater":"It can't be retrieved at the moment. Please wait a moment",
        "pool.op.minute":"min",
        "pool.op.hour":"hour",
        "pool.op.day":"day",
        "pool.op.Retrieve":"Retrieve",
        "pool.op.Notice":"Note: 0.01% commission is required for contract transfer",
        "pool.op.addTip":"be careful:\n" +
            "1. The cold start period has passed, normal income\n" +
            "2. Normal income formula: my income per minute ≈ my ratio * 48",

        "My.security": "Accounts & Security",
        "My.language": "Switch Language",
        "My.nodes": "Switch Node",
        "My.about": "About",
        "My.address": "Address",
        "My.contact": "Contact Us",
        "My.security.exportPrivateKey": "Export Privatekey",
        "My.security.exportPrivateKey.title": "About Privatekey",
        "My.security.exportPrivateKey.subtitle": "Privatekey is used to import and manage the money account. It's danger if lose it.",
        "My.security.exportPrivateKey.tip1": "Write to more than 2 papers, and save to secure place seperately.",
        "My.security.exportPrivateKey.tip2": "Don't store it in the phone, formats regardless.",
        "My.security.exportPrivateKey.tip3": "Don't tell anyone.",
        "My.security.exportKeystore": "Export Keystore",
        "My.security.modifyPassword": "Modify Password",
        "My.security.modifyPassword.old": "Original password",
        "My.security.modifyPassword.new": "New password",
        "My.security.modifyPassword.new2": "Confirm new password",
        "My.security.modifyPassword.oldError": "original password invalid",
        "My.security.modifyPassword.newError": "Password must be contains 6-12 alphanumber and special characters.",
        "My.security.modifyPassword.newErrorNotMatch": "Fails to confirm new password",
        "My.security.modifyPassword.success": "Operation success.",
        "My.security.deleteWallet": "Sign Out",
        "My.security.deleteWallet.mustExport": "Privatekey must exported",
        "My.security.deleteWallet.mustExportDesc": "Please export privatekey, then delete wallet",
        "My.language.zh": "Chinese",
        "My.language.en": "English",
        "My.nodes.hongkong": "Node two",
        "My.nodes.china": "Node one",
        "My.about.version": "walletapp version",
        "My.about.checkNewVersion": "Check New Version",

        "AuthDialog.please": "Please authenticate",
        "AuthDialog.pleaseEnterPassword": "Please enter your wallet password",

        "DApp.ETHmappingAddress":'Eth mapping address',
        "DApp.SmartXAPP":'SmartX Application',
        "DApp.applyETHAddress":"Apply for eth mapping address",
        "DApp.SmartXService":"SmartX service ",
        "DApp.crossChainAssets":'OrcaOTC',
        'DApp.SmartXChat':'Private mail',
        'DApp.DAPPEcology':'DAPP Ecology',
        'DApp.redEnvelope':'Red Envelope',
        'DApp.water':'Faucet',
        'DApp.daomin':"DMShop",
        'DApp.contractStore':'Contract Store',
        'DApp.DEXExchange':'KittySwap',
        'DApp.MappingCompleted':'Mapping completed',
        'DApp.MappingCompletedTip':'The mapping has been completed. If there are any tokens that have not been mapped, please replace the wallet mapping.',

        'RedEnvelope.Blessing':"Congratulations on fortune",
        'RedEnvelope.NumberOf':'Number :',
        'RedEnvelope.NumberTip':'Number ',
        'RedEnvelope.Unit':'',
        'RedEnvelope.Type':'Type :',
        'RedEnvelope.Type1':'To be lucky',
        'RedEnvelope.Amount':'Amount :',
        'RedEnvelope.AmountTip':'Amount',
        'RedEnvelope.ButtonTitle':'Send',
        'RedEnvelope.24HourTip':'If not received within 24 hours, the red envelope amount will be refunded',
        'RedEnvelope.RedEnvelopeAccount':'Red envelope account',
        'RedEnvelope.SendingRedEnvelope':'Sending red envelope, please wait',
        'RedEnvelope.AlertNumOrTotal':'Please enter the correct amount or quantity',
        'RedEnvelope.AlertNum':'Maximum number of red packets: 200',
        'RedEnvelope.AlertTotal':'The average amount of red envelopes shall not be less than 0.05',
        'RedEnvelope.SendError':'Failed to send red envelope, please try again later',

        'RedEnvelopeInfo.Bless':'Good luck',
        'RedEnvelopeInfo.NumberOf':'Number of red envelope(s)',
        'RedEnvelopeInfo.InfoTip':' red envelopes,Total',
        'RedEnvelopeInfo.sFinish':' seconds to ',
        'RedEnvelopeInfo.mFinish':'minutes to finish',
        'RedEnvelopeInfo.hFinish':'hours to finish',
        'RedEnvelopeInfo.Waiting':'Waiting',
        'RedEnvelopeInfo.Success':'Success',
        'RedEnvelopeInfo.Record':'Record(s)',
        'RedEnvelopeInfo.Share':'Share',
        'RedEnvelopeInfo.RedEnvelopeHash':'Envelope No. ',
        'RedEnvelopeInfo.AlertSendFalse':'Failed to send red envelope, please try again later',
        'RedEnvelopeInfo.AlertSendFalseSave':'The red envelope failed to be sent，Can be resent in the upper right corner',
        'RedEnvelopeInfo.AlertSendFalseNum':'The red envelope failed to be sent, and the system is busy. code:0100',
        'RedEnvelopeInfo.King':'King',
        'RedEnvelopeInfo.TranSuccess':'Transaction completed',
        'RedEnvelopeInfo.TranWaiting':'Transaction in progress',
        'RedEnvelopeInfo.ViewTran':'View transaction',

        'RedEnvelopeLoad.Type':'Sent a lucky red envelope',
        'RedEnvelopeLoad.Title':'Make a fortune, good luck',
        'RedEnvelopeLoad.View':'Check friend\'s luck',
        'RedEnvelopeLoad.AlertLater':'Better luck next time',

        'RedEnvelopeList.Received':'Received',
        'RedEnvelopeList.Send':'Send',
        'RedEnvelopeList.ReceivedAll':'Red envelope received,Total',
        'RedEnvelopeList.SendAll':'Red envelope send,Total',
        'RedEnvelopeList.Year':'Year',
        'RedEnvelopeList.Type':'Red Envelope',
        'RedEnvelopeList.From':'',
        'RedEnvelopeList.Contains':'',
        'RedEnvelopeList.RedEnvelopes':'RedEnvelope(s)',
        'RedEnvelopeList.Success':'Success',
        'RedEnvelopeList.SuccessSend':'Success',
        'RedEnvelopeList.Waiting':'Waiting',
        'RedEnvelopeList.Show50':'Show the last 50 red envelopes',

        'RedEnvelopeIndex.Type':'Lucky Red Envelope',
        'RedEnvelopeIndex.Title1':'Send blessing in red envelope',
        'RedEnvelopeIndex.Title2':'Receive red envelopes to gather luck',
        'RedEnvelopeIndex.PlaceHold':'Enter your password',
        'RedEnvelopeIndex.Get':'Get',
        'RedEnvelopeIndex.Record':'View red envelope record(s)',
        'RedEnvelopeIndex.Contract':'Pledge contract',
        'RedEnvelopeIndex.Tip':'Sending',
        "RedEnvelopeIndex.Alert":"The red envelope is sent successfully, click OK to copy the password",
        "RedEnvelopeIndex.RedEnvelopeNumber":"Number",
        "RedEnvelopeIndex.RedEnvelopeTotal" :"Amount",
        "RedEnvelopeIndex.RedEnvelopePassword" :"Password",
        "RedEnvelopeIndex.RedEnvelopeWarn" :'No such password',
        "RedEnvelopeIndex.RedEnvelopeTip1":"【SMARTX】",
        "RedEnvelopeIndex.RedEnvelopeTip2":"Welcome to SMARTXapp to grab red envelopes",
        "RedEnvelopeIndex.RedEnvelopeTip3":"Or click this link to grab red envelope:",

        "RedEnvelopeAlert.Ready":"Ready",
        "RedEnvelopeAlert.CopyPass":"Copy Password",
        "RedEnvelopeAlert.Back":"Back",
        "RedEnvelopeAlert.Info":"RedEnvelope Info",
        "RedEnvelopeAlert.Num":"Number",
        "RedEnvelopeAlert.Total":"Total",
        "RedEnvelopeAlert.Password":"Password",

        "RedRepub.SmallTitle":"Redistributable red envelope",

        "SetMyInfo.Title":"My Profile",
        "SetMyInfo.ProfilePhoto":"Profile Photo",
        "SetMyInfo.Name":"Name",

        "SetName.Title":"Edit Name",
        "SetName.placeHolder":"Edit Name",

        "enter": "Enter",
        "ok": "OK",
        "clearAll":"ClearAll",
        "DeTail":"Details",
        "confirm": "Confirm",
        "cancel": "Cancel",
        "ETHSATBalance":"Balance",
        "copy": "Copy",
        "copied": "Copied.",
        "next": "Next",
        "pay":'Pay',
        "noContent": "no content",
        "comingSoon":"Coming soon",
        "checkNewversion":'New version detected, update now?',
        "isDownLoad":"Downloading, please wait...",
        "isNewVersion":"It's the latest version!",
        "officialWebsite":"Check the official website",
        "updateWebsite":"Update log",
        "updateUrl":"https://red.smartx.one/#/update?lang=en",
        "Number":"Number",
        "Total":"Total Amount",

        'title.browser':"SmartX Explore",
        "title.RedEnvelope":"SmartX RedEnvelope",
        "title.RedEnvelopeInfoTitle":"SmartX RedEnvelope",
        "title.RedEnvelopeListTitle":"SmartX RedEnvelope",

        "serviceChargeError":"Input amount is wrong, please reserve 0.002SAT service charge in your wallet",

        "errorTip_1":"The node has no block permission",
        "errorTip_2":"Error in signing",
        "errorTip_3":"The balance is less than 0.002, and the handling fee cannot be deducted",
        "errorTip_4":"Transfer out account does not exist",
        "errorTip_5":"Insufficient transfer out balance",
        "errorTip_6":"More than 8 decimal places",
        "errorTip_7":"Node congestion",
        "errorTip_8":"Same access address",
        "errorTip_9":"Transaction already exists",
        "errorTip_10":"Invalid transfer in address",
        "errorTip_11":"Transaction package size exceeds limit",

        "authorized":"Is it authorized?",

        "tokenInfo.Title":"Base Info:",
        "tokenInfo.Web":"Website:",
        "tokenInfo.ConAddress":"Contract:",
        "tokenInfo.WhitePaper":"White Paper:",
        "tokenInfo.Name":"Token Name:",
        "tokenInfo.Short":"Token abbreviation:",
        "tokenInfo.Total":"Total Supply:",
        "tokenInfo.Null":"Not yet",

        "QR_code":"My QR code",
        "QR_code_Tip":"Scan the QR code above, and send me a message",
        "QR_Scan_Title":"Scan QR code",
        "QR_Scan_Tip":"Scan the transfer QR code / Message QR code",

        "MeChat":"Message",
        "MeChat_FirstSet_Title":"First login",
        "MeChat_FirstSet_Search":"Query data",
        "MeChat_FirstSet_SearchTime":"Query on-chain data ",
        "MeChat_FirstSet_AddCustomer":"Add customer",
        "MeChat_FirstSet_ShowStats":"Display status",

        "MeChat_ChatList_Title":"Message.Beta",
        "MeChat_ChatList_Tip1":"Getting network data",
        "MeChat_ChatList_Tip2":"Parsing network data",


        "MeChat_ChatView_Send":"Send",
        "MeChat_ChatView_TipBeforeNonce":"Get the nonce value ",
        "MeChat_ChatView_TipAfterNonce":"Get the nonce value：",
        "MeChat_ChatView_TipGetBestNode":"Get the best node：",
        "MeChat_ChatView_TipTranFinish":"Send transaction is broadcast",
        "MeChat_ChatView_TipGetHeight":"Get the current height：",
        "MeChat_ChatView_TipEncryptionFinish":"Data encryption completed",
        "MeChat_ChatView_TipOnChain":"The message is on the chain, please wait ",

        "MeChat_SetParams_Title":"Options",
        "MeChat_SetParams_MainTitle":"Settings",
        "MeChat_SetParams_Search":"Query data",
        "MeChat_SetParams_Interval":"Query data interval",
        "MeChat_SetParams_SearchTime":"Query on-chain data",
        "MeChat_SetParams_AddCustomer":"Add customer",
        "MeChat_SetParams_ShowStats":"Display status",
        "MeChat_SetParams_SearchUnit":"",
        "MeChat_SetParams_IntervalUnit":"s",
        "MeChat_SetParams_SearchTimeUnit":"week(s)",
        "MeChat_SetParams_GetAllMessage":"Query all chat records",
        "MeChat_SetParams_Analyze":"Perform data analysis >",

        "MeChat_SetParams_Toast_MaxSearch":"Maximum query of 1000 transactions",
        "MeChat_SetParams_Toast_MinInterval":"The minimum query interval is 8 seconds",
        "MeChat_SetParams_Toast_MaxSearchTime":"Maximum query time 20 weeks",

        "MeChat_SetParams_BTNClose":"Close",
        "MeChat_SetParams_BTNShow":"Show",
        "MeChat_SetParams_BTNAdd":"Add",
        "MeChat_SetParams_BTNIN":"Enter",

        "MeChat_SetParams_AlertTitle":"Query all chat records",
        "MeChat_SetParams_AlertMessage":"To query all chat records, you need to find all your records on the chain, so depending on your transaction volume and network conditions, it may take a long time. Are you sure you need to query all chat records?",

        "AutoSearch":"Auto Search Best Pool",
        "Web_Search":"Search",

        "Node_MyNode":"My Node",
        "Node_AddNode": "Add Node",
        "Node_NodeName":"Node Name",
        "Node_NodeIp":"Node Ip",
        "Node_NodePort":"Port",
        "Node_AlreadyExists":"NodeName already exists",
        "Node_IPErrorPrompt":"Node ip needs to start with http:// or https://",
        "Node_PortErrorPrompt":"Please input node port",

        "NFT_Add_Hot":"Hot NFTs",
        "NFT_Add_Cancle":"Cancle",

        "NFT_Contract_Detail":"NFT Details",
        "NFT_Contract_Assets":"Assets",

        "NFT_Detail":"NFT Details",
        "NFT_Detail_Profile":"Profile",
        "NFT_Detail_NoName":"No name yet",
        "NFT_Detail_NOProfile":"No profile yet",
        "NFT_Detail_SendFile":"Send",
        "NFT_Detail_SaveImg":"save to the album",
        "NFT_Detail_Cancle":"cancel",

        "NFT_Transfer":"transfer",
        "NFT_Transfer_receiver":"Receiver",
        "NFT_Transfer_sendNFT":"Send NFT",
        "NFT_Transfer_send":"Send",
        "NFT_Transfer_TranDetail":"Transaction Details",
        "NFT_Transfer_Sender":"Sender",
        "NFT_Transfer_ContractAddr":"Contract",
        "NFT_Transfer_Confirm":"Confirm Payment",
        "NFT_Transfer_InputPwd":"Verify password",
        "NFT_Transfer_Sending":"Sending",
    },
    'zh': {
        'Guest.slogan': '欢迎来到SmartX社区',
        'Guest.register': '注册钱包',
        'Guest.import': '导入钱包',

        "Register.memo": "钱包备注",
        "Register.passwordPlaceholder": "请输入钱包密码",
        "Register.repassword": "请确认密码",
        "Register.passwordError": "请输入密码",
        "Register.repasswordError": "两遍密码必须一致",
        "Register.read": "我已阅读并同意",
        "Register.privacy": "服务及隐私条款",

        "Import.password": "密码",
        "Import.passwordError": "密码错误",
        "Import.privateKey": "私钥",
        'Import.keyStore':"钱包文件",
        "Import.correctPrivatekey":"私钥错误",
        "Import.invalid": "格式错误",

        "Tabs.assets": "资产",
        "Tabs.apps": "应用",
        "Tabs.pool": "矿池",
        "Tabs.my": "我的",
        "Tabs.chat":"邮箱",
        "Tabs.group":"Group",
        "Tabs.HotAssets": "热门资产",

        "Assets.wallet": "钱包",
        "Assets.balance": "总资产(SAT)",
        "Assets.send": "转账",
        "Assets.preSend":"转账列表",
        "Assets.receive": "收款",
        "Assets.txs": "交易记录",
        "Assets.scanQrcode": "扫描二维码",
        "Assets.receive.switch": "切换",
        "Assets.txs.all": "全部",
        "Assets.txs.pending": "等待处理",
        "Assets.txs.id": "交易号",
        "Assets.txs.out": "转出",
        "Assets.txs.in": "转入",
        "Assets.txs.success": "成功",
        "Assets.txs.waiting": "转账中",
        "Assets.txs.lose": "丢失",
        "Assets.txs.failure": "失败",
        "Assets.txs.resend": "重发",
        "Assets.tx.title": "交易详情",
        "Assets.tx.sender": "付款账号",
        "Assets.tx.receiver": "收款账号",
        "Assets.tx.gas": "已支付网络费",
        "Assets.tx.timestamp": "交易时间",
        "Assets.tx.blockNumber": "区块号",
        "Assets.tx.hash": "交易号",
        "Assets.tx.remarks": "备注",
        "Assets.tx.Blockbrowser": "区块浏览器",
        "Assets.tx.data": "交易数据",
        "Assets.tx.contractCall":"合约调用",
        "Assets.tx.contractRelease":"合约发布",

        "Assets.send.receiver": "收款账号",
        "Assets.send.sendToAccount": "账号转账",
        "Assets.send.scan": "扫码转账",
        "Assets.send.recent": "最近转账",
        "Assets.send.amount": "转账金额",
        "Assets.send.remarks": "备注",
        "Assets.send.balance": "余额",
        "Assets.send.pledge": "质押",
        "Assets.send.all": "全部",
        "Assets.send.selectAsset": "选择资产",
        "Assets.send.receiverInvalid": "请输入正确的收款账号",
        "Assets.send.cannotToSelf": "不能给自己转账",
        "Assets.send.mustSelectCoin": "请选择资产",
        "Assets.send.amountInvalid": "请输入正确的金额",
        "Assets.send.balanceNotEnough": "余额不足",
        "Assets.send.sendFail": "交易发送失败，请稍后重试",
        "Assets.send.sendSuccess": "交易已广播",
        "Assets.send.OK": "确定",
        "Assets.confirmDelete":"确定删除 ",

        "Assets.send.payDetailTitle": "支付详情",//TODO 2021-03-07
        "Assets.send.payDetailReceiver": "收款账户",//TODO 2021-03-07
        "Assets.send.payDetailTitleSender": "付款账户",//TODO 2021-03-07
        "Assets.send.payDetailBtnOK": "确定",//TODO 2021-03-07
        "Assets.send.pwHint": "钱包密码",//TODO 2021-03-07
        "Assets.send.pwReset": "忘记密码？",//TODO 2021-03-07
        "Assets.send.Notice":"注意：转账需收取0.002SAT的手续费，请注意余额！",

        "Txs.AlertDel":"确认删除该信息。",

        "Token.tokenSearch":"代币搜索",
        "Token.tokenNonExit":"该代币不存在",
        "Token.hotTokens":"热门代币",


        "Pool.title": '智图合约', //TODO 2021-03-08
        "Pool.zyhy.create": '创建质押合约',//TODO 2021-03-08
        "pool.zyhy.releaseHY":'合约解除',
        "pool.zyhy.moveHY":'合约转移',
        "pool.zyhy.getHY":'合约取回',
        "pool.zyhy.recallHY":'撤销合约',
        "pool.zyhy.decideRecallHY":'确定撤销取回合约吗？',

        "pool.zyhy.addHY":'合约添加',
        "Pool.zyhy.qryHint": '合约搜索',//TODO 2021-03-08
        "Pool.zyhy_my": '我的质押',//TODO 2021-03-08
        "Pool.zyhy_all": '质押合约',//TODO 2021-03-08
        "Pool.zyhy_zjc": '资金池',//TODO 2021-03-08
        "Pool.zyhy_nhl": '年化率',//TODO 2021-03-08
        "Pool.zyhy_zt": '状态',//TODO 2021-03-08
        "Pool.zyhy_zed": '总凭证',//TODO 2021-03-08
        "Pool.zyhy_myzb": '我的占比',//TODO 2021-03-08
        "Pool.zyhy_mypz": '我的凭证',//TODO 2021-03-08
        "Pool.zyhy_mysy": '我的余额',//TODO 2021-03-08
        "Pool.zyhy_rec": '当前 zhy 条',//TODO 2021-03-08
        "Pool.zyhy.createHint": '可用奖金池',//TODO 2021-03-08
        "Pool.zyhy.create_moneyHint": '输入合约金额',//TODO 2021-03-08
        "Pool.btn_create": '创建',//TODO 2021-03-08
        "Pool.op.btn_create": '添加',//TODO 2021-03-08
        "Pool.op.btn_modife": '转移',//TODO 2021-03-08
        "Pool.op.btn_delete": '解除',//TODO 2021-03-08
        "Pool.op.qhpz": '取回凭证',//TODO 2021-03-08
        'Pool.op.zypz': '转移凭证',//TODO 2021-03-23
        "Pool.op.pzcountHint": '请输入凭证数量',//TODO 2021-03-08
        "Pool.op.zb25": '25%',//TODO 2021-03-08
        "Pool.op.zb50": '50%',//TODO 2021-03-08
        "Pool.op.zb75": '75%',//TODO 2021-03-08
        "Pool.op.zbMax": 'MAX',//TODO 2021-03-08
        "Pool.op.kypz": '可用凭证：',//TODO 2021-03-08
        "Pool.op.zb": '占比：',//TODO 2021-03-08
        "Pool.op.zyzc": '转移资产',//TODO 2021-03-08
        "Pool.op.zcmoneyHint": '请输入资产金额',//TODO 2021-03-08
        "Pool.op.zyz": '转移至',//TODO 2021-03-08
        "Pool.op.hyaddrHint": '请输入合约地址',//TODO 2021-03-08
        "Pool.op.qhzc": '取回资产',//TODO 2021-03-08
        "Pool.op.qhzt": '取回状态',//TODO 2021-03-08
        "Pool.op.btnqh": '取回',//TODO 2021-03-08
        "Pool.op.xh": '序号',//TODO 2021-03-08
        "Pool.op.je": '金额',//TODO 2021-03-08
        "Pool.op.zt": '状态',//TODO 2021-03-08
        "Pool.op.recall": '撤回',

        "Pool.op.hyH": '时',//TODO 2021-03-08
        "Pool.op.hyM": '分',//TODO 2021-03-08
        "Pool.op.hyS": '秒',//TODO 2021-03-08
        "Pool.op.hyHint": '后可确认取',//TODO 2021-03-08
        "Pool.op.qrmoney": '确认金额',//TODO 2021-03-08
        "Pool.op.qrmoneyHint": '请输入添加的金额',//TODO 2021-03-08
        "Pool.op.blc": '余额：',//TODO 2021-03-08
        'Pool.op.excuting': '合约操作执行中,请等待',//TODO 2021-03-26
        "pool.op.pooling":"正在进行合约",
        "pool.op.addMoneyError":"添加金额必须大于1000SAT",
        "pool.op.releaseMoneyError":"解除金额错误",
        "pool.op.moveMoneyError":"转移金额错误",
        "pool.op.moveAddressError":"转移地址错误",
        "pool.op.minCreateContract":"创建合约要求:最少100000SAT",
        "pool.op.contractNonExit":"该合约不存在",
        "pool.op.tryLater":'请稍后再试！',
        "pool.op.getLater":"暂时不可取回，请稍等",
        "pool.op.minute":"分钟",
        "pool.op.hour":"小时",
        "pool.op.day":"天",
        "pool.op.Retrieve":"解除",
        "pool.op.Notice":"注意：合约转移需收取0.01%的手续费",
        "pool.op.addTip":"注意：\n" +
            "1、冷启动期已过，收益正常\n" +
            "2、正常收益公式：每分钟我的收益 ≈ 我的占比*48",

        "My.security": "账户与安全",
        "My.language": "语言切换",
        "My.nodes": "节点切换",
        "My.about": "关于我们",
        "My.address": "地址",
        "My.contact": "联系客服",
        "My.security.exportPrivateKey": "导出私钥",
        "My.security.exportPrivateKey.title": "关于私钥",
        "My.security.exportPrivateKey.subtitle": "私钥用于导入和管理账户，丢失私钥可能引发账户风险",
        "My.security.exportPrivateKey.tip1": "抄写至少两份到纸张上，分开保管在安全的地方",
        "My.security.exportPrivateKey.tip2": "不要存在手机里，例如文字，图片或者视频的形式",
        "My.security.exportPrivateKey.tip3": "千万不要告诉任何人",
        "My.security.exportKeystore": "导出Keystore",
        "My.security.modifyPassword": "修改密码",
        "My.security.modifyPassword.old": "旧密码",
        "My.security.modifyPassword.new": "新密码",
        "My.security.modifyPassword.new2": "重复新密码",
        "My.security.modifyPassword.oldError": "旧密码错误",
        "My.security.modifyPassword.newError": "请输入新密码",
        "My.security.modifyPassword.newErrorNotMatch": "两遍新密码必须一致",
        "My.security.modifyPassword.success": "密码修改成功。",
        "My.security.deleteWallet": "退出登录",
        "My.security.deleteWallet.mustExport": "私钥还未导出",
        "My.security.deleteWallet.mustExportDesc": "请先导出私钥，再删除账户",
        "My.language.zh": "中文",
        "My.language.en": "英文",
        "My.nodes.hongkong": "节点二",
        "My.nodes.china": "节点一",
        "My.about.version": "钱包版本",
        "My.about.checkNewVersion": "检测更新",

        "AuthDialog.please": "请认证",
        "AuthDialog.pleaseEnterPassword": "请输入钱包密码",

        "DApp.ETHmappingAddress":'我的ETH映射地址',
        "DApp.SmartXAPP":'智图应用',
        "DApp.applyETHAddress":"申请ETH映射地址",
        "DApp.SmartXService":"智图服务",
        "DApp.crossChainAssets":'OrcaOTC',
        'DApp.SmartXChat':'私密邮件',
        'DApp.DAPPEcology':'DAPP生态',
        'DApp.redEnvelope':'红包打赏',
        'DApp.water':'水龙头',
        'DApp.daomin':"岛民商城",
        'DApp.contractStore':'合约商店',
        'DApp.DEXExchange':'KittySwap',
        'DApp.MappingCompleted':'映射已完成',
        'DApp.MappingCompletedTip':'已完成映射，如果还有未完成映射的代币，请更换钱包映射。',

        'RedEnvelope.Blessing':"恭喜发财，大吉大利",
        'RedEnvelope.NumberOf':'红包个数',
        'RedEnvelope.NumberTip':'红包数量',
        'RedEnvelope.Unit':'个',
        'RedEnvelope.Type':'红包类型',
        'RedEnvelope.Type1':'拼手气',
        'RedEnvelope.Amount':'红包金额',
        'RedEnvelope.AmountTip':'金额',
        'RedEnvelope.ButtonTitle':'塞进红包',
        'RedEnvelope.24HourTip':'24小时内未被领取,红包金额将退回',
        'RedEnvelope.RedEnvelopeAccount':'红包账户',
        'RedEnvelope.SendingRedEnvelope':'红包正在发送',
        'RedEnvelope.AlertNumOrTotal':'请输入正确的金额或者数量',
        'RedEnvelope.AlertNum':'红包最大数量：200',
        'RedEnvelope.AlertTotal':'红包平均金额不得小于0.05',
        'RedEnvelope.SendError':'红包发送失败，请稍后再试',

        'RedEnvelopeInfo.Bless':'祝你好运',
        'RedEnvelopeInfo.NumberOf':'红包个数',
        'RedEnvelopeInfo.InfoTip':'个红包，共',
        'RedEnvelopeInfo.sFinish':'秒抢完',
        'RedEnvelopeInfo.mFinish':'分抢完',
        'RedEnvelopeInfo.hFinish':'小时抢完',
        'RedEnvelopeInfo.Waiting':'转账中',
        'RedEnvelopeInfo.Success':'成功',
        'RedEnvelopeInfo.Record':'红包记录',
        'RedEnvelopeInfo.Share':'分享红包',
        'RedEnvelopeInfo.RedEnvelopeHash':'红包编号：',
        'RedEnvelopeInfo.AlertSendFalse':'红包发送失败，请稍后再试',
        'RedEnvelopeInfo.AlertSendFalseSave':'红包发送失败，可在右上角进行重新发送',
        'RedEnvelopeInfo.AlertSendFalseNum':'红包发送失败，系统繁忙。code:0100',
        'RedEnvelopeInfo.King':'运气王',
        'RedEnvelopeInfo.TranSuccess':'交易已完成',
        'RedEnvelopeInfo.TranWaiting':'交易进行中',
        'RedEnvelopeInfo.ViewTran':'查看交易',


        'RedEnvelopeLoad.Type':'发送了一个拼手气红包',
        'RedEnvelopeLoad.Title':'恭喜发财，好运连连',
        'RedEnvelopeLoad.View':'看看朋友的手气',
        'RedEnvelopeLoad.AlertLater':'手速慢了，没有抢到红包',

        'RedEnvelopeList.Received':'我收到的',
        'RedEnvelopeList.Send':'我发出的',
        'RedEnvelopeList.ReceivedAll':'个红包收到，共',
        'RedEnvelopeList.SendAll':'个红包发出，共',
        'RedEnvelopeList.Year':'年',
        'RedEnvelopeList.Type':'红包',
        'RedEnvelopeList.From':'',
        'RedEnvelopeList.Contains':'包',
        'RedEnvelopeList.RedEnvelopes':'个红包',
        'RedEnvelopeList.Success':'已领取',
        'RedEnvelopeList.SuccessSend':'已发送',
        'RedEnvelopeList.Waiting':'进行中',
        'RedEnvelopeList.Show50':'最近 50 个红包',

        'RedEnvelopeIndex.Type':'拼手气红包',
        'RedEnvelopeIndex.Title1':'发红包 送祝福',
        'RedEnvelopeIndex.Title2':'收红包 聚手气',
        'RedEnvelopeIndex.PlaceHold':'输口令，拼手气',
        'RedEnvelopeIndex.Get':'确定',
        'RedEnvelopeIndex.Record':'查看红包记录',
        'RedEnvelopeIndex.Contract':'质押合约',
        'RedEnvelopeIndex.Tip':'发送红包中',
        "RedEnvelopeIndex.Alert":"红包发送成功，点击确定复制口令，将红包分享给朋友吧。",
        "RedEnvelopeIndex.RedEnvelopeNumber":"红包个数",
        "RedEnvelopeIndex.RedEnvelopeTotal" :"红包金额",
        "RedEnvelopeIndex.RedEnvelopePassword" :"红包口令",
        "RedEnvelopeIndex.RedEnvelopeWarn" :'没有此口令',
        "RedEnvelopeIndex.RedEnvelopeTip1":"【SMARTX】",
        "RedEnvelopeIndex.RedEnvelopeTip2":"下载钱包app一起抢红包:",
        "RedEnvelopeIndex.RedEnvelopeTip3":"或点击此链接一起抢红包:",

        "RedEnvelopeAlert.Ready":"红包已备好",
        "RedEnvelopeAlert.CopyPass":"复制红包口令",
        "RedEnvelopeAlert.Back":"返回红包界面",
        "RedEnvelopeAlert.Info":"红包信息",
        "RedEnvelopeAlert.Num":"红包数量",
        "RedEnvelopeAlert.Total":"红包金额",
        "RedEnvelopeAlert.Password":"红包口令",

        "RedRepub.SmallTitle":"可重新发布的红包",
        "SetMyInfo.Title":"个人信息",
        "SetMyInfo.ProfilePhoto":"头像",
        "SetMyInfo.Name":"昵称",

        "SetName.Title":"设置昵称",
        "SetName.placeHolder":"请输入昵称",



        "enter": "请输入",
        "ok": "确认",
        "clearAll":"全部清空",
        "DeTail":"详情",
        "confirm": "确认",
        "cancel": "取消",
        "ETHSATBalance":"余额",
        "copy": "复制",
        "copied": "复制成功",
        "next": "下一步",
        "pay":'支付',
        "noContent": "无数据",
        "comingSoon":"敬请期待",
        "checkNewversion":'检测到新版本,是否立即更新?',
        "isDownLoad":"正在下载,请稍后...",
        "isNewVersion":"已经是最新版本！",
        "officialWebsite":"查看官网",
        "updateWebsite":"更新日志",
        "updateUrl":"https://red.smartx.one/#/update?lang=zh",
        "Number":"数量",
        "Total":"总金额",


        'title.browser':"区块浏览器",
        "title.RedEnvelope":"智图红包",
        "title.RedEnvelopeInfoTitle":"智图红包",
        "title.RedEnvelopeListTitle":"智图红包",
        "serviceChargeError":"输入金额有误，请预留0.002SAT手续费在钱包中",

        "errorTip_1":"节点无出块权限",
        "errorTip_2":"验签错误",
        "errorTip_3":"余额小于0.002,无法扣除手续费",
        "errorTip_4":"转出账户不存在",
        "errorTip_5":"转出余额不足",
        "errorTip_6":"小数点后位数超过8",
        "errorTip_7":"节点拥堵",
        "errorTip_8":"出入地址相同",
        "errorTip_9":"交易已存在",
        "errorTip_10":"转出地址无效",
        "errorTip_11":"交易包大小超过限制",

        "authorized":"是否授权？",

        "tokenInfo.Title":"基本信息:",
        "tokenInfo.Web":"官网:",
        "tokenInfo.ConAddress":"合约地址:",
        "tokenInfo.WhitePaper":"白皮书:",
        "tokenInfo.Name":"代币名称:",
        "tokenInfo.Short":"代币简称:",
        "tokenInfo.Total":"代币总量:",
        "tokenInfo.Null":"暂无",

        "QR_code":"二维码名片",
        "QR_code_Tip":"扫一扫上面的二维码，加我发信息",
        "QR_Scan_Title":"扫描二维码",
        "QR_Scan_Tip":"扫描转账二维码 / 聊天二维码",

        "MeChat":"Message",
        "MeChat_FirstSet_Title":"首次登录Message",
        "MeChat_FirstSet_Search":"首次查询数据",
        "MeChat_FirstSet_SearchTime":"首次查询网络数据",
        "MeChat_FirstSet_AddCustomer":"添加Message客服",
        "MeChat_FirstSet_ShowStats":"显示通讯状态",
        "MeChat_ChatList_Title":"Message实验版",
        "MeChat_ChatList_Tip1":"正在获取网络数据",
        "MeChat_ChatList_Tip2":"正在解析网络数据",
        "MeChat_ChatView_Send":"发送",
        "MeChat_ChatView_TipBeforeNonce":"获取nonce值中",
        "MeChat_ChatView_TipAfterNonce":"获取到nonce值：",
        "MeChat_ChatView_TipGetBestNode":"获取到最佳节点：",
        "MeChat_ChatView_TipTranFinish":"发送交易已广播",
        "MeChat_ChatView_TipGetHeight":"获取到当前高度：",
        "MeChat_ChatView_TipEncryptionFinish":"数据加密完成",
        "MeChat_ChatView_TipOnChain":"消息发送中，请等待",

        "MeChat_SetParams_Title":"选项",
        "MeChat_SetParams_MainTitle":"设置",
        "MeChat_SetParams_Search":"查询数据",
        "MeChat_SetParams_Interval":"查询间隔",
        "MeChat_SetParams_SearchTime":"查询网络数据",
        "MeChat_SetParams_AddCustomer":"添加Message客服",
        "MeChat_SetParams_ShowStats":"显示通讯状态",
        "MeChat_SetParams_SearchUnit":"条",
        "MeChat_SetParams_IntervalUnit":"秒",
        "MeChat_SetParams_SearchTimeUnit":"周",
        "MeChat_SetParams_GetAllMessage":"分析网络数据",
        "MeChat_SetParams_Analyze":"进行数据分析 >",
        "MeChat_SetParams_Toast_MaxSearch":"最大查询1000笔交易",
        "MeChat_SetParams_Toast_MinInterval":"最小查询间隔8秒",
        "MeChat_SetParams_Toast_MaxSearchTime":"最大查询时间20周",

        "MeChat_SetParams_BTNClose":"关闭",
        "MeChat_SetParams_BTNShow":"显示",
        "MeChat_SetParams_BTNAdd":"添加",
        "MeChat_SetParams_BTNIN":"进入",

        "MeChat_SetParams_AlertTitle":"分析网络数据",
        "MeChat_SetParams_AlertMessage":"查询所有聊天记录，需要去网络查找您所有的记录，所以根据你的交易数量和网络状况，可能需要较久的时间。确定需要查询所有聊天记录吗？",

        "AutoSearch":"自动搜索最佳矿池",
        "Web_Search":"搜索",

        "Node_MyNode":"我的节点",
        "Node_AddNode":"添加节点",
        "Node_NodeName":"节点名称",
        "Node_NodeIp":"IP地址",
        "Node_NodePort":"端口",
        "Node_AlreadyExists":"节点名称已存在",
        "Node_IPErrorPrompt":"节点ip需要以 http:// 或 https:// 开头",
        "Node_PortErrorPrompt":"请输入节点端口",

        "NFT_Add_Hot":"热门 NFT",
        "NFT_Add_Cancle":"取消",

        "NFT_Contract_Detail":"NFT 详情",
        "NFT_Contract_Assets":"资产",

        "NFT_Detail":"NFT 详情",
        "NFT_Detail_Profile":"介绍",
        "NFT_Detail_NoName":"暂无名称",
        "NFT_Detail_NOProfile":"暂无简介",
        "NFT_Detail_SendFile":"发送",
        "NFT_Detail_SaveImg":"保存图片",
        "NFT_Detail_Cancle":"关闭",

        "NFT_Transfer":"转账",
        "NFT_Transfer_receiver":"收款地址",
        "NFT_Transfer_sendNFT":"发送NFT",
        "NFT_Transfer_send":"发送",
        "NFT_Transfer_TranDetail":"交易详情",
        "NFT_Transfer_Sender":"付款地址",
        "NFT_Transfer_ContractAddr":"合约地址",
        "NFT_Transfer_Confirm":"确认发送",
        "NFT_Transfer_InputPwd":"输入密码",
        "NFT_Transfer_Sending":"转账中",


    },
};

class Locale {
    lang: string;

    constructor(lang: string) {
        this.lang = lang;
    }

    _(key: string) {
        return l10n[this.lang][key];
    }
}

export const useLocale = (): [Locale | null, (v: string) => void] => {
    const [locale, setLocale] = useState<Locale | null>(null);

    const wrapSetLocale = (lang: string) => {
        const work = async () => {
            setLocale(new Locale(lang));

            try {
                await AsyncStorage.setItem('@lang', lang)
            } catch (e) {
                console.log('@lang set', e);
            }
        };

        work();
    };

    useEffect(() => {
        const work = async () => {
            var lang: string | null = null;

            try {
                lang = await AsyncStorage.getItem('@lang');
            } catch (e) {
                console.log('@lang get', e);
            }

            if (!lang) {
                lang = RNLocalize.getLocales()[0].languageCode;
                if(lang!="en" && lang!='zh' )
                {
                    console.log(typeof (lang))
                    console.log("lang is en or zh==>"+lang)
                    lang="en";
                }
                else
                {
                    lang="en";
                }
            }
            setLocale(new Locale(lang));
            await AsyncStorage.setItem('@lang', lang)
        };
        work();
    }, []);


    return [locale, wrapSetLocale];
};

const LocaleContext = React.createContext<Locale | null>(null);

export default LocaleContext;
